home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / VIEWS.ZIP;1 / CVDZIP.EXE / CVCLASS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-30  |  3.6 KB  |  168 lines

  1. /*
  2.     cvclass.cpp
  3.  
  4.     Class hierarchy window (main window)
  5.     
  6.     C++/Views 2.0 Demo
  7.     Copyright (c) 1992, by Liant Software Corp.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12. */
  13.  
  14. #include "cvclass.h"
  15. #include "cvdemovw.h"
  16. #include "listbox.h"
  17. #include "port.h"
  18. #include "font.h"
  19. #include "brush.h"
  20. #include "shade.h"
  21. #include "messengr.h"
  22. #include "tagstrm.h"
  23. #include "editbox.h"
  24.  
  25. #include "cvclinfo.h"
  26. #include "cvcltree.h"
  27.  
  28. defineClass(ClassView, VMdiView)
  29.  
  30. ClassView::ClassView()
  31. {
  32.     ;
  33. }
  34.  
  35. ClassView::ClassView(VFrame &f, DemoAppView *parent)
  36.     : VMdiView("ClassIcon", f, (VWindow *) parent, StyleBorder | StyleTitle | StyleCloseBox | StyleSizable)
  37. {
  38.     mainWin = parent;
  39.  
  40.     setTitle("C++/Views Classes");
  41.  
  42.     setBackground(new VBrush(LightGray));
  43.  
  44.     /* create an edit box */
  45.     msgBox = new VEditBox(VFrame(0.4F, 0.0F, 0.6F, 0.3F), this,
  46.                     StyleBorder | StyleVertical | StyleWordWrap | StyleReadOnly);
  47.  
  48.  
  49.     textFont = new VFont("New Times Roman", 11, TRUE);
  50.     msgBox->setFont(textFont);
  51.  
  52.     /* create a list box */
  53.     listBox = new VListBox(VFrame(0.0F, 0.0F, 0.4F, 0.3F), this, StyleBorder);
  54.     listBox->uponClick(this, methodOf(ClassView, listClick),
  55.                              methodOf(ClassView, listDblClick));
  56.  
  57.     listBox->setFont(textFont);
  58.  
  59.     /* create the class tree view */
  60.     treeView = new ClassTreeView(VFrame(0.0F, 0.3F, 1.0F, 0.7F), this);
  61.     treeView->uponClick(this, methodOf(ClassView, classSelected));
  62.  
  63.     /* load the starting messages */
  64. //    treeView->loadFromStream(cvTextFile->getMessage("ClassList:Data Classes"));
  65.     treeView->update();
  66.     msgBox->putText(cvTextFile->getMessage("ClassIntro:General").gets());
  67.  
  68.     /* read in list of class lists from the message file */
  69.     VTagStream    tagStrm;
  70.     VString        cmd;
  71.     VStream        clist(cvTextFile->getMessage("ClassList:List"));
  72.  
  73.     tagStrm.beginScan(&clist, NIL);
  74.     tagStrm.tags('(', ')');
  75.  
  76.     while(tagStrm.getTag(cmd)) {
  77.         listBox->appendString(cmd.gets());
  78.     }
  79.  
  80.     /* make sure the "About this Window" data is set up */
  81.     mainWin->setAboutNames("Class:About", "cvclass.cpp");
  82. }
  83.  
  84. ClassView::~ClassView()
  85. {
  86.     /* destroy background brush (if present) */
  87.     delete getBackground();
  88.  
  89.     delete textFont;
  90. }
  91.  
  92. boolean ClassView::free()
  93. {
  94.     delete this;
  95.     return(TRUE);
  96. }
  97.  
  98. boolean ClassView::close()
  99. /*
  100.     The user has closed the window.
  101.     Notify the main window so that it can update the main menu bar
  102. */
  103. {
  104.     mainWin->classView = 0;
  105.     mainWin->updateMenu();
  106.     return(FALSE);
  107. }
  108.  
  109. boolean ClassView::listClick(int index)
  110. /*
  111.     Mouse clicked on the list box
  112. */
  113. {
  114.     VString    idx("ClassList:");
  115.     VString *temp;
  116.  
  117.     temp = listBox->selectedString();
  118.     idx.concat(temp);
  119.  
  120.     /* load a new class tree */
  121.     treeView->loadFromStream(cvTextFile->getMessage(idx.gets()));
  122.     treeView->update();
  123.  
  124.     /* update the message */
  125.     idx.puts("ClassIntro:");
  126.     idx.concat(temp);
  127.     msgBox->putText(cvTextFile->getMessage(idx.gets()).gets());
  128.  
  129.     delete temp;
  130.  
  131.     return(TRUE);
  132. }
  133.  
  134. boolean ClassView::listDblClick(int index)
  135. /*
  136.     Mouse double-clicked on the list box
  137. */
  138. {
  139.     return(TRUE);
  140. }
  141.  
  142. boolean ClassView::classSelected()
  143. {
  144.     ClassInfo *cinfo = treeView->getCurrClass();
  145.  
  146.     if (cinfo) {
  147.         /* update message text */
  148.         VString    idx("Class:");
  149.         idx.concat(cinfo->getName());
  150.         msgBox->putText(cvTextFile->getMessage(idx.gets()).gets());
  151.     }
  152.  
  153.     return(TRUE);
  154. }
  155.  
  156. boolean ClassView::givenFocus()
  157. /*
  158.     Our window has just been given input focus
  159. */
  160. {
  161.     /* set the data for the About this Window dialog */
  162.     mainWin->setAboutNames("Class:About", "cvclass.cpp");
  163.  
  164.     /* carry on with default window behavior, return FALSE */
  165.     return(FALSE);
  166. }
  167.  
  168.